﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace OnlineGameClient.Control
{
    public partial class MyProgressBar : UserControl
    {
        public MyProgressBar()
        {
            InitializeComponent();
        }
        
        public double Value
        {
            get { return (double)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }

        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(double), typeof(MyProgressBar)
            , new PropertyMetadata(
                new PropertyChangedCallback((s, e) =>
                    {
                        var myprogressbar = s as MyProgressBar;
                        if ((double)e.OldValue == 0 && (double)e.NewValue > 0)
                        {
                            myprogressbar.actiontimershowsb1.Begin();
                        }
                        if ((double)e.NewValue == 100)
                        {
                            myprogressbar.actiontimerhidesb1.Begin();
                        }
                        myprogressbar.pb.Value = (double)e.NewValue;
                    })));

        public bool AutoHide
        {
            get { return (bool)GetValue(AutoHideProperty); }
            set { SetValue(AutoHideProperty, value); }
        }

        public static readonly DependencyProperty AutoHideProperty =
            DependencyProperty.Register("AutoHide", typeof(bool), typeof(MyProgressBar)
            , new PropertyMetadata(
                new PropertyChangedCallback((s, e) =>
                    {
                        //
                    })));

        
    }
}
